<template>
	<view class="status">
		订单状态查询中...
	</view>
</template>

<script>
	// import 'dingtalk-jsapi/entry/mobile';
	// import openLink from 'dingtalk-jsapi/api/biz/util/openLink';
	
	export default {
		data() {
			return {
				url: ''
			}
		},
		onLoad(e) {
			console.log('当前的e', e)
			// console.log('this.$store.state.linkOrderNo', this.$store.state.linkOrderNo)
			if(this.$store.state.linkOrderNo) {
				const orderNo = this.$store.state.linkOrderNo
				setTimeout(() => {
					if(orderNo.startsWith('N')) {
						// 企业充值订单
						this.getCorpinfo(orderNo)
					} else {
						this.getOrderinfo(orderNo)
					}
				}, 2000)
				this.$store.commit('changeLinkOrderNo', '')
				// console.log('this.$store.state.linkOrderNo2', this.$store.state.linkOrderNo)
			}
		},
		methods: {
			getCorpinfo(orderNo) {
				this.$ajax({
				  method: 'get',
				  url: '/outing/mobile/corpinfo/queryByOrderNo',
					data: {
						orderNo
					}
				}).then(res => {
					if(res.data && res.data.payStatus) {
						if(res.data.payStatus === 'SUCCESS') {
							uni.redirectTo({
								url: `/subPages/personalCenter/recharge/success?orderNo=${orderNo}`
							})
						} else {
							uni.redirectTo({
								url: `/subPages/personalCenter/recharge/fail?orderNo=${orderNo}`
							})
						}
					}
				});
			},
			getOrderinfo(orderNo) {
				this.$ajax({
				  method: 'get',
				  url: '/outing/mobile/order/queryByOrderNo',
					data: {
						orderNo
					}
				}).then(res => {
					if(res.data && res.data.payStatus) {
						if(res.data.payStatus === 'SUCCESS') {
							uni.redirectTo({
								url: `/pages/common/paySuccess?orderNo=${orderNo}`
							})
						} else {
							uni.redirectTo({
								url: `/pages/common/payFail?orderNo=${orderNo}`
							})
						}
					}
				});
			}
		}
	}
</script>

<style>
.status {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
}
</style>
